package com.dove.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {
    private String code;
    private String msg;
    private Object data;
    private Boolean flag;

    /**
     * 成功
     *  不需要数据，如删除
     *  需要数据，如查询
     */

    public static Result success() {
        return new Result(Constants.CODE_200, "", null,true);
    }

    public static Result success(String msg) {
        return new Result(Constants.CODE_200, msg, null,true);
    }

    public static Result success(Object data) {
        return new Result(Constants.CODE_200, "success", data,true);
    }

    /**
     * 失败只需要原因吧
     */
    public static Result error() {
        return new Result(Constants.CODE_500, "系统错误", null,false);
    }

    public static Result error(String msg) {
        return new Result(Constants.CODE_CUSTOM_MSG, msg, null,false);
    }

    public static Result error(String code, String msg) {
        return new Result(code, msg, null,false);
    }

}
